﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AwesomeEnginePC.Extentions
{
    public static class ExtMedIEnumerableBasics
    {

        /// <summary>
        /// Converts a list into a character delimited string.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="list"></param>
        /// <param name="delimiter">The value to separate the values with.</param>
        /// <returns></returns>
        public static string ToCSVString<T>(this List<T> list, string delimiter)
        {
            string output = "";

            if (list.Count == 0)
            {
                return output;
            }

            list.ForEach((x) => { output += x.ToString() + delimiter; });

            output = output.Remove(output.LastIndexOf(delimiter));

            return output;
        }

    }
}
